const moduleB = {
  namespaced: true,
  state: {
    list: [],
  },
  mutations: {
    getList(state, payload) {
      state.list = payload.result;
    },
  },
  actions: {
    asyncGetList({ commit }) {
      // 目的就是让组件里面知道actions的异步什么时候结束
      return new Promise((resolve) => {
        fetch("http://www.pudge.wang:3080/api/rated/list")
          .then((response) => response.json())
          .then((res) => {
            commit("getList", res);
            resolve();
          });
      });
    },
  },
};

export default moduleB;
